import * as func from "./func.js"
/*表单*/
import { getField } from "@/common.js"
import { commonForm } from "./commonForm.js"
import { cusLayoutForm } from "./cusLayoutForm.js"
import { customForm } from "./customForm.js"
import CusSplit from "./components/CusSplit/index.vue"
import CusText from "./components/CusText/index.vue"
import CusDivide from "./components/CusDivide/index.vue"
import CusInput from "./components/CusInput/index.vue"
import CusTextArea from "./components/CusTextArea/index.vue"
import CusRadio from "./components/CusRadio/index.vue"
import CusCheckBox from "./components/CusCheckBox/index.vue"
import CusSelect from "./components/CusSelect/index.vue"
import CusDate from "./components/CusDate/index.vue"
import CusDateRange from "./components/CusDateRange/index.vue"
import CusUploadImg from "./components/CusUploadImg/index.vue"
import CusUploadFile from "./components/CusUploadFile/index.vue"
import CusBloodPressure from "./components/CusBloodPressure/index.vue"
import CusPulseDorsalis from "./components/CusPulseDorsalis/index.vue"
import CusCurrentAndTarget from "./components/CusCurrentAndTarget/index.vue"
import CusMedicine from "./components/CusMedicine/index.vue"
import CusSymptom from "./components/CusSymptom/index.vue"
/*表单配置*/
import CusSplitSet from "./formSet/CusSplitSet/index.vue"
import CusTextSet from "./formSet/CusTextSet/index.vue"
import CusDivideSet from "./formSet/CusDivideSet/index.vue"
import CusInputSet from "./formSet/CusInputSet/index.vue"
import CusTextAreaSet from "./formSet/CusTextAreaSet/index.vue"
import CusRadioSet from "./formSet/CusRadioSet/index.vue"
import CusCheckBoxSet from "./formSet/CusCheckBoxSet/index.vue"
import CusSelectSet from "./formSet/CusSelectSet/index.vue"
import CusDateSet from "./formSet/CusDateSet/index.vue"
import CusDateRangeSet from "./formSet/CusDateRangeSet/index.vue"
import CusUploadFileSet from "./formSet/CusUploadFileSet/index.vue"
import CusUploadImgSet from "./formSet/CusUploadImgSet/index.vue"
import CusBloodPressureSet from "./formSet/CusBloodPressureSet/index.vue"
import CusPulseDorsalisSet from "./formSet/CusPulseDorsalisSet/index.vue"
import CusCurrentAndTargetSet from "./formSet/CusCurrentAndTargetSet/index.vue"
import CusMedicineSet from "./formSet/CusMedicineSet/index.vue"
import CusSymptomSet from "./formSet/CusSymptomSet/index.vue"
/*预览表单*/
import PreviewForm from "@/components/PreviewForm/index.vue"
/*自定义modal弹框*/
import ExportJson from "./funcComponents/ExportJson/index.vue"
import ImportJson from "./funcComponents/ImportJson/index.vue"
export default {
  name: '',
  components:{
    /*组件*/
    CusSplit, CusText,CusDivide,CusInput,CusTextArea,CusRadio,CusCheckBox,CusSelect,CusDate,CusDateRange,CusUploadImg,
    CusUploadFile,CusBloodPressure,CusPulseDorsalis,CusCurrentAndTarget,CusMedicine,CusSymptom, 
    /*设置*/
    CusSplitSet,CusTextSet,CusDivideSet,CusInputSet,CusTextAreaSet,CusRadioSet,CusCheckBoxSet,CusSelectSet,CusDateSet,CusDateRangeSet,CusUploadFileSet,
    CusUploadImgSet,CusBloodPressureSet,CusPulseDorsalisSet,CusCurrentAndTargetSet,CusMedicineSet,CusSymptomSet,
    /** 业务组件*/
    PreviewForm,ExportJson,ImportJson
  },
  data(){
    return {
      modalType: 0, // 0:关闭弹框 1:   2：列表中表单预览   3：编辑预览
      dragType: 1, // 1、新增表单   2、表单排序
      // 左侧
      cusLayoutForm: Object.freeze(cusLayoutForm), // 用户布局字段
      commonForm: Object.freeze(commonForm), // 通用表单
      customForm: Object.freeze(customForm), // 用户自定义表单
      curFormObj: {}, // 当前拖拽的表单类型
      // 中间
      formData:{
        name: '',
        visitType:'', // 随访类型
        illustrate: '',
      },
      formRule: {
        name: [{required: true, message: '请输入表单名称', trigger: 'change'}, {max:20, message:'表单名称长度不得超过20位'}, {min:1, message:'表单名称长度不得小于1位'}],
        visitType: [{required: true, message: '请选择随访类型', trigger: 'change'}],
      },
      radioList: [{id:1, name: '编辑', isChecked: true}, {id:2, name:'预览', isChecked: false}],
      operateForm: [], // 中间的表单
      checkedItem:{}, // 中间选中的表单
      isShowAni: false, // 是否显示动画
      curIndex: 0, // 当前默认选中的表单(调整顺序时)
      mouseHoverItem: {}, // 鼠标触碰到的表单序号
      direction: '', // top 向上  bottom 向下 
      timeId: null,
      // 右侧
      tabIndex: 0,
      isShowExportJson: false, // 是否显示导出json组件
      isShowImportJson: false, // 是否显示导入json组件
    }
  },
  computed:{
    formType: function(){
      return getField(this.radioList, 'id', v => v.isChecked).join('')
    },
  },
  methods:{
    ...func,
  },
  async created(){
    this.getFormList()
  },
  mounted(){
    this.getPosition() // 表单初始化需要给设置一个初始的定位的位置
    this.bindArrow()
  },
}